<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('controller列列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                            <li>
                                <p>url：</p>
                                <input type="text" name="requestUrl"/>
                            </li>
                            <li>
                                <p>方法名：</p>
                                <input type="text" name="methodName"/>
                            </li>
                            <li>
                                <p>方法类型：</p>
                                <select name="methodType">
                                    <option value="">所有</option>
                                    <option value="GET">GET</option>
                                    <option value="POST">POST</option>
                                </select>
                            </li>

                            <li>
                                <p>状态：</p>
                                <select name="urlStatus">
                                    <option value="">所有</option>
                                    <option value="1">启用</option>
                                    <option value="0">禁用</option>
                                </select>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" >
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" >
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning  multiple disabled" onclick="tagging()" >
                    <i class="fa fa-tags"></i> 打标签
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "url";

        $(function() {
            var options = {
                url: prefix + "/list",
                detailUrl: prefix + "/detail/{id}",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "controller列",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'urlId', 
                    title : '主键',
                    visible: false
                },
                {
                    field : 'controllerId', 
                    title : '组id',
                    visible: false
                },
                {
                    field : 'requestUrl', 
                    title : 'url'
                },
                {
                    field : 'methodName', 
                    title : '方法名'
                },
                {
                    field : 'methodType', 
                    title : '方法类型'
                },
                // {
                //     field : 'methodContentType',
                //     title : '请求方式'
                // },
                // {
                //     field : 'requestParamMap',
                //     title : '请求参数',
                //     formatter: function(value, row, index) {
                //         return $.table.tooltip(value);
                //     }
                // },
                // {
                //     field : 'returnParamClass',
                //     title : '返回对象class',
                //     visible: false
                // },
                // {
                //     field : 'returnParamMap',
                //     title : '返回参数',
                //     formatter: function(value, row, index) {
                //         return $.table.tooltip(value);
                //     }
                // },
                {
                    field : 'urlStatus', 
                    title : '状态'
                },
                {
                    field : 'urlLabel', 
                    title : '标签',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field : 'methodDesc', 
                    title : '描述',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }

                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.urlId + '\')"><i class="fa fa-search"></i>编辑</a> ');
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.urlId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.urlId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function detail(urlId) {
            var url = prefix + '/detail/' + urlId;
            $.modal.openTab("接口详情", url);
        }

        //打标签
        function tagging() {
            var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            var data = { "ids": rows.join() };

            $.modal.alertWarning("选中的id：" +  rows.join());

        }

    </script>
</body>
</html>